﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;

namespace Mimoza.PluginLayer
{
    public class PluginResultStore
    {
        static public void PutResult(PluginResult result)
        {
            Thread.SetData(Thread.GetNamedDataSlot(DataSlotName),
                result);
        }

        static public void PutRestartResult()
        {
            PluginResult result = new PluginResult();
            result.NeedToReboot = true;

            Common.Logger.Log.Info("PluginResultStore.PutRestartResult.");

            PluginResultStore.PutResult(result);
        }

        static public void ResetResult()
        {
            PutResult(null);
        }

        static public PluginResult GetResult()
        {
            return Thread.GetData(Thread.GetNamedDataSlot(DataSlotName)) as 
                PluginResult;
        }

        const string DataSlotName = "PluginResult";
    }
}
